package com.gaogzhen.juc.atomic.integer;

import java.util.concurrent.atomic.AtomicInteger;

public class TestAtmoticInteger {
    public static void main(String[] args) {
        AtomicInteger ai = new AtomicInteger(10);
        ai.updateAndGet(n ->  n * 10);
        System.out.println(ai.get());

        while (true) {
            int prev = ai.get();
            int next = prev * 10;
            if (ai.compareAndSet(prev, next)) {
                break;
            }
        }
        System.out.println(ai.get());
    }
}
